package com.easy.dn.ui.usercenter.presenter;

import com.easy.common.baserx.RxSubscriber;
import com.easy.dn.bean.CodeBean;
import com.easy.dn.bean.CodeVerificationBean;
import com.easy.dn.bean.UserInfoBean;
import com.easy.dn.ui.usercenter.contract.RegisterContract;

import java.util.Map;

/**
 * Created by DN on 2017/5/3.
 */

public class RegisterPresenter extends RegisterContract.Presenter {

    //登录
    @Override
    public void getUserInfoData(Map<String, String> map) {
        mRxManage.add(mModel.ObtainUserInfoData(map).subscribe(new RxSubscriber<UserInfoBean>(mContext,true) {
            @Override
            protected void _onNext(UserInfoBean bean) {
                mView.returnUserInfoData(bean);
            }

            @Override
            protected void _onError(String message) {
                mView.showErrorTip(message);
            }
        }));
    }

    //获取是否显示图形验证码
    @Override
    public void getCodeInfoData(Map<String, String> map) {
        mRxManage.add(mModel.ObtainCodeInfoData(map).subscribe(new RxSubscriber<CodeBean>(mContext,true) {
            @Override
            protected void _onNext(CodeBean bean) {
                mView.returnCodeInfoData(bean);
            }

            @Override
            protected void _onError(String message) {
                mView.showErrorTip(message);
            }
        }));
    }
    //注册
    @Override
    public void getRegistgerData(Map<String, String> map) {

        mRxManage.add(mModel.ObtainRegistgerData(map).subscribe(new RxSubscriber<UserInfoBean>(mContext,true) {
            @Override
            protected void _onNext(UserInfoBean bean) {
                mView.returnRegistgerData(bean);
            }

            @Override
            protected void _onError(String message) {
                mView.showErrorTip(message);
            }
        }));

    }

    @Override
    public void getCodeVerificationData(Map<String, String> map) {
        mRxManage.add(mModel.ObtainVerificationData(map)
                .subscribe(new RxSubscriber<CodeVerificationBean>(mContext,false) {
            @Override
            protected void _onNext(CodeVerificationBean bean) {

                mView.returnCodeVerificationData(bean);
            }

            @Override
            protected void _onError(String message) {
                mView.showErrorTip(message);
            }
        }));

    }
}
